function mapList(data) {
	var code = data.code;
	var data = data.data;
	if(code != 1) {
		alert(data.msg);
		return false;
	}
	var oHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + data.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + data.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + data.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + data.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + data.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="topFun($(this))" data-up="' + data.up + '">上翻</a></div></div>';
	$(".map-one").html(oHtml);

	var tData = data.son;

	//二级
	if(tData == "") {
		var zcHtml = '<div class="map-center-xq"><a href="#" class="map-zchy">请注册会员</a></div>'
		$(".map-two-l,.map-two-r").html(zcHtml);
	} else if(tData.length == 1) {
		$.each(tData, function(i, v) {
			if(v.area == 1) {
				var tHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + v.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + v.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + v.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + v.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + v.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange erji" onclick="topFun($(this))" data-up="' + v.up + '">上翻</a><a href="#" class="f-orange erji" onclick="btnFun($(this))" data-down="' + v.down + '">下翻</a></div></div>'
				$(".map-two-l").html(tHtml);
				$(".map-two-r").html(zcHtml);
				//三级	
				var slData = v.son;
				if(slData == "") {
					var szcHtml = '<div class="map-center-xq"><a href="#" class="map-zchy">请注册会员</a></div>'
					$(".map-thr-l-left,.map-thr-l-right").html(szcHtml);
				} else {
					$.each(slData, function(j, k) {
						if(k.area == 1) {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-left").html(slHtml);
						} else {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-right").html(slHtml);
						}
					})
				}
			} else {
				var tHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + v.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + v.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + v.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + v.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + v.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange erji" onclick="topFun($(this))" data-up="' + v.up + '">上翻</a><a href="#" class="f-orange erji" onclick="btnFun($(this))" data-down="' + v.down + '">下翻</a></div></div>'
				$(".map-two-l").html(zcHtml);
				$(".map-two-r").html(tHtml);
				//三级	
				var slData = v.son;
				if(slData == "") {
					var szcHtml = '<div class="map-center-xq"><a href="#" class="map-zchy">请注册会员</a></div>'
					$(".map-thr-l-left,.map-thr-l-right").html(szcHtml);
				} else {
					$.each(slData, function(j, k) {
						if(k.area == 1) {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-left").html(slHtml);
						} else {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-right").html(slHtml);
						}
					})
				}

			}

		})

	} else {
		$.each(tData, function(i, v) {
			if(v.area == 1) {
				var tHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + v.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + v.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + v.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + v.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + v.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange erji" onclick="topFun($(this))" data-up="' + v.up + '">上翻</a><a href="#" class="f-orange erji" onclick="btnFun($(this))" data-down="' + v.down + '">下翻</a></div></div>'
				$(".map-two-l").html(tHtml);

				//三级	
				var slData = v.son;
				if(slData == "") {
					var szcHtml = '<div class="map-center-xq"><a href="#" class="map-zchy">请注册会员</a></div>'
					$(".map-thr-l-left,.map-thr-l-right").html(szcHtml);
				} else {
					$.each(slData, function(j, k) {
						if(k.area == 1) {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-left").html(slHtml);
						} else {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-l-right").html(slHtml);
						}
					})
				}
			} else {
				var tHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + v.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + v.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + v.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + v.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + v.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange erji" onclick="topFun($(this))" data-up="' + v.up + '">上翻</a><a href="#" class="f-orange erji" onclick="btnFun($(this))" data-down="' + v.down + '">下翻</a></div></div>'
				$(".map-two-r").html(tHtml);

				//三级
				var slData = v.son;
				if(slData == "") {
					var szcHtml = '<div class="map-center-xq"><a href="#" class="map-zchy">请注册会员</a></div>'
					$(".map-thr-r-left,.map-thr-r-right").html(szcHtml);
				} else {
					$.each(slData, function(j, k) {
						if(k.area == 1) {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-r-left").html(slHtml);
						} else {
							var slHtml = '<div class="map-center-xq"><p class="f-gray">编号：<span class="cen f-black">' + k.mid + '</span></p><p class="f-gray">等级：<span class="cen f-black">' + k.level_name + '</span></p><p class="f-gray">大区：<span class="cen f-black">' + k.area_remark + '</span></p><p class="f-gray">名称：<span class="cen f-black">' + k.mname + '</span></p><p class="f-gray">累计：<span class="cen f-black">' + k.score_total + '</span></p><div class="map-btn"><a href="#" class="f-orange" onclick="btnFun($(this))" data-down="' + k.down + '">下翻</a></div></div>'
							$(".map-thr-r-right").html(slHtml);
						}
					})
				}
			}

		});

	}
}

//function getMap(mid){

//			html += '<div class="a">'+data.data.mid+'[<a href="javascript:;" onclick="getMap(\''+data.data.up+'\')">上</a>][<a href="javascript:;" onclick="getMap(\''+data.data.down+'\')">下</a>]</div>';
//			$.each(data.data.son,function(index,value){
//				if(JSON.stringify(value) === '[]'){
//					html += '<div class="b">————注册新用户</div>';
//				}else{
//					html += '<div class="b">————'+value.mid+'[<a href="javascript:;" onclick="getMap(\''+value.up+'\')">上</a>][<a href="javascript:;" onclick="getMap(\''+value.down+'\')">下</a>]</div>';
//					$.each(value.son,function(i,v){
//						if(JSON.stringify(v) === '[]'){
//							html += '<div class="b">————————注册新用户</div>';
//						}else{
//							html += '<div class="c">————————'+v.mid+'[<a href="javascript:;" onclick="getMap(\''+v.up+'\')">上</a>][<a href="javascript:;" onclick="getMap(\''+v.down+'\')">下</a>]</div>';
//						}
//					})
//				}
//				
//			})
//	}
//});
//}

function topFun($this) {
	layer.msg('数据加载中...', {
		icon: 16,
		shade: 0.3,
		success: function() {
			var up = $this.attr("data-up");
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: 'mid=' + up,
				url: listSrc,
				success: function(data) {
					layer.close(layer.index);
					mapList(data);
				}
			})
		}
	})

}

function btnFun($this) {
	layer.msg('数据加载中...', {
		icon: 16,
		shade: 0.3,
		success: function() {
			var down = $this.attr("data-down");
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: 'mid=' + down,
				url: listSrc,
				success: function(data) {
					layer.close(layer.index);
					mapList(data);
				}
			})
		}
	})

}

$(function() {
	layui.use('layer', function() {
		var $ = layui.jquery,
			layer = layui.layer;
		layer.msg('数据加载中...', {
			icon: 16,
			shade: 0.3,
			success: function() {
				$.ajax({
					type: 'post',
					dataType: 'json',
					data: 'mid=' + fid,
					url: listSrc,
					success: function(data) {
						layer.close(layer.index);
						mapList(data);
					}
				})
			}
		})
	})

	$("#ScreenBnt").click(function() {
		var mid = $.trim($("#input-mid").val())
		if(mid == "") {
			layer.alert('请输入会员编号！', {
				icon: 5
			})
			return false;
		}
		layer.msg('数据加载中...', {
			icon: 16,
			shade: 0.3,
			success: function() {
				$.ajax({
					type: 'post',
					dataType: 'json',
					data: 'mid=' + mid,
					url: listSrc,
					success: function(data) {
						layer.close(layer.index);
						mapList(data);
					}
				})
			}
		})
		
		

	})
});